package com.qf.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * Created by 54110 on 2021/6/22.
 */
@Component
@Aspect
public class MyAop {


    @Pointcut("execution(* *.*.service.impl.*.*(..))")
    public void pt1(){

    }

    @Around("pt1()")
    public Object around(ProceedingJoinPoint joinPoint){
        Object proced=null;
        try {
            System.out.println("进入了方法");
            proced= joinPoint.proceed();
            System.out.println("离开了方法");
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            System.out.println("发生异常 ex:"+throwable.getMessage());
        }finally {
            System.out.println("方法执行完成");
        }
        return proced;
    }
}
